﻿

Imports System.Object
Imports VSModel
Imports Cls_Common
Imports System.IO
Imports System.Data

Partial Class FrontEnd_Control_News_BigBanner
    Inherits System.Web.UI.UserControl

#Region "Sub and function"
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            LoadData()
        End If
    End Sub
    Private Sub LoadData()
        Using Data As New VSEntities
            Dim p = (From q In Data.Contents Where q.IsHot = True And q.StatusId = 3 And q.PublishedDate <= Now() And (q.eEffectiveDate >= Now() Or q.eEffectiveDate Is Nothing) Order By q.PublishedDate Descending
                     Select q.Id, q.Title, q.Description, q.Image, q.ImageBig, q.PublishedDate, q.bEffectiveDate, q.QueryString).Skip(0).Take(5).ToList()
            rptShow.DataSource = p
            rptShow.DataBind()

            rptNote.DataSource = p
            rptNote.DataBind()
        End Using
    End Sub
#End Region

#Region "Event for control"
    Protected Sub rptShow_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptShow.ItemDataBound
        Dim row = CType(e.Item.DataItem, Object)
        Dim img As Image = CType(e.Item.FindControl("img"), Image)
        Dim ltrTitle As Literal = CType(e.Item.FindControl("ltrTitle"), Literal)
        Dim ltrDes As Literal = CType(e.Item.FindControl("ltrDes"), Literal)
        Dim hplMore As HyperLink = CType(e.Item.FindControl("hplMore"), HyperLink)
        Dim hplImg As HyperLink = CType(e.Item.FindControl("hplImg"), HyperLink)
        Dim hplTile As HyperLink = CType(e.Item.FindControl("hplTile"), HyperLink)

        img.ImageUrl = row.ImageBig 'CookedImageURL("750-340", )

        ltrTitle.Text = row.Title.ToString
        ltrDes.Text = row.Description.ToString
        hplMore.NavigateUrl = MainDomain & "tin-tuc-chi-tiet/" & row.QueryString & "-" & row.Id.ToString & ".html"
        hplImg.NavigateUrl = MainDomain & "tin-tuc-chi-tiet/" & row.QueryString & "-" & row.Id.ToString & ".html"
        hplTile.NavigateUrl = MainDomain & "tin-tuc-chi-tiet/" & row.QueryString & "-" & row.Id.ToString & ".html" '"#Category-" & (e.Item.ItemIndex + 1).ToString

    End Sub

    Protected Sub rptNote_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptNote.ItemDataBound
        Dim row = CType(e.Item.DataItem, Object)
        Dim img As Image = CType(e.Item.FindControl("img"), Image)
        Dim ltrTitle As Literal = CType(e.Item.FindControl("ltrTitle"), Literal)
        Dim ltrDes As Literal = CType(e.Item.FindControl("ltrDes"), Literal)
        Dim hplMore As HyperLink = CType(e.Item.FindControl("hplMore"), HyperLink)
        Dim lblDate As Label = CType(e.Item.FindControl("lblDate"), Label)
        img.ImageUrl = row.Image 'CookedImageURL("80-80",)
        ltrTitle.Text = row.Title
        ltrDes.Text = row.Description
        '   lblDate.Text = Convert.ToDateTime(row.bEffectiveDate).ToString("dd/MM/yyyy")
    End Sub
#End Region
End Class
